/**
 * Licensee: Anonymous
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class ListEstateData {
	private static final int ROW_COUNT = 100;
	
public void listTestData() throws PersistentException {
		com.estate.datalogic.DAOFactory lDAOFactory = com.estate.datalogic.DAOFactory.getDAOFactory();
		System.out.println("Listing Ad_type...");
		com.estate.datalogic.Ad_type[] comestatedatalogicAd_types = lDAOFactory.getAd_typeDAO().listAd_typeByQuery(null, null);
		int length = Math.min(comestatedatalogicAd_types.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(comestatedatalogicAd_types[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Advertisement...");
		com.estate.datalogic.Advertisement[] comestatedatalogicAdvertisements = lDAOFactory.getAdvertisementDAO().listAdvertisementByQuery(null, null);
		length = Math.min(comestatedatalogicAdvertisements.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(comestatedatalogicAdvertisements[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Client...");
		com.estate.datalogic.Client[] comestatedatalogicClients = lDAOFactory.getClientDAO().listClientByQuery(null, null);
		length = Math.min(comestatedatalogicClients.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(comestatedatalogicClients[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing County...");
		com.estate.datalogic.County[] comestatedatalogicCountys = lDAOFactory.getCountyDAO().listCountyByQuery(null, null);
		length = Math.min(comestatedatalogicCountys.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(comestatedatalogicCountys[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Country...");
		com.estate.datalogic.Country[] comestatedatalogicCountrys = lDAOFactory.getCountryDAO().listCountryByQuery(null, null);
		length = Math.min(comestatedatalogicCountrys.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(comestatedatalogicCountrys[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Town...");
		com.estate.datalogic.Town[] comestatedatalogicTowns = lDAOFactory.getTownDAO().listTownByQuery(null, null);
		length = Math.min(comestatedatalogicTowns.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(comestatedatalogicTowns[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listClientByuid() {
		System.out.println("Listing Client by uid...");
		// Please uncomment the follow lines and fill in parameters 
		//com.estate.datalogic.Client[] clients = com.estate.datalogic.DAOFactory.getDAOFactory().getClientDAO().listByuid();
		//int length = clients == null ? 0 : Math.min(clients.length, ROW_COUNT);
		//for (int i = 0; i < length; i++) {
			//System.out.println(clients[i]);
		//}
		//System.out.println(length + " record(s) retrieved.");
	}
	
	public static void main(String[] args) {
		try {
			ListEstateData listEstateData = new ListEstateData();
			try {
				listEstateData.listTestData();
				//listEstateData.listClientByuid();
			}
			finally {
				com.estate.datalogic.EstatePersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
